﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;

namespace GuitarChordFinder
{
    public class AudioFileSourceConverter : IValueConverter
    {
        private List<string> fileTypes = new List<string>{".mp3", ".wav"};

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return string.Empty;
            string path = value.ToString();
            if (path.Length == 0) return string.Empty; ;
            
            string suffix = path.Substring(path.Length-4);

            if (fileTypes.Contains(suffix))
                return path;
            else
                return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // TODO:
            return value;
        }
    }
}
